package com.woniuxy.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.woniuxy.entity.Remark;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.entity.User;
import com.woniuxy.service.RemarkServive;
import com.woniuxy.util.CommonUtil;
/**
 * 评论
 * @author Administrator 曾令忠
 *
 */
@Controller
@RequestMapping("/remark")
public class RemarkController {
	@Autowired
	private RemarkServive remarkService;
	
	@RequestMapping("/addRemark")
	@ResponseBody
	public ResponseEntity<Void> addRemark(long oid,String mark,String content){
		ResponseEntity<Void> re = new ResponseEntity<Void>();
		User user = CommonUtil.getCurrentUser();
		try {
			int res = remarkService.addRemark(oid,user.getId(),mark,content);
			if(res==3) {
				re.setCode(3);//该订单已被评价过
				return re;
			}
			re.setCode(1);
		} catch (Exception e) {
			e.printStackTrace();
			re.setCode(2);
		}
		return re;
	}
}
